#include <simulator/simulator.h>

std::shared_ptr<TargetMachine> Simulator::getDspMachine(){
    return m_targetMachine;
}

void Simulator::addTimer(std::shared_ptr<Timer> &timer) {
    m_timers.push_back(timer);
}


void Simulator::nextCycle() {
    m_timers[0]->incrementCycle();
}

void Simulator::addInstIntoDelayQueue(std::shared_ptr<Instruction> &instruction) {
    u64 delay = instruction->getDelay();
    // 指令需要执行的所有时钟周期
    std::list<u64> allCycle;
    while (delay != 0) {
        allCycle.push_front(m_timers[0]->getCycle() + delay);
        --delay;
    }
    m_delayQueue.emplace(m_timers[0]->getCycle(), allCycle, instruction);
}
